package dd.prog2.exercises.set05;

import java.util.Scanner;

public class _main {

	public static void main(String[] args) {

		Tsp tsp = null;
		Scanner sc = new Scanner(System.in);
		int sel = 0;
		String userInput = "";
		do {
			try {
				System.out.println("TSP auswaehlen(1-3): ");
				userInput = sc.nextLine();
				sel = Integer.parseInt(userInput);
				if (sel == 1 || sel == 2 || sel == 3)
					break;
				else
					throw new Exception();
			} catch (Exception e) {
				System.err.println("nur Zahlen 1-3 erlaubt");
			}
		} while (true);

		if (sel == 1) {
			tsp = new Tsp1();
		} else if (sel == 2) {
			tsp = new Tsp2();
		} else if (sel == 3) {
			tsp = new Tsp3();
		}

		tsp.asGraph();
		Trip trip = new Trip(tsp.length());
		tsp.calcTSP(tsp, trip);
		System.out.printf(trip.toString());
	}
}
